//
//  MyScorllView.m
//  UI06_UIScrollView_相册
//
//  Created by wyx on 16/3/16.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "MyScorllView.h"

@implementation MyScorllView
#pragma mark - creating and init
- (instancetype)initWithFrame:(CGRect)frame withImage:(NSArray<UIImage *> *)images {
    self = [super initWithFrame:frame];
    if (self) {
        [self configWithFrame:frame andImages:images];
    }
    return self;
}
#pragma mark - config
- (void)configWithFrame:(CGRect)frame andImages:(NSArray *)images {
    //设置contentSize
    self.contentSize = CGSizeMake(frame.size.width * images.count, frame.size.height);
    //创建 ImageView 子视图
    for (int i = 0; i < images.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:images[i]];
        imageView.frame = CGRectMake(frame.size.width * i, 0, frame.size.width, frame.size.height);
        [self addSubview: imageView];
        [imageView release];
        
    }
    //设置翻页效果
    self.pagingEnabled = YES;
    //边缘回弹效果
    self.bounces = YES;
    //滑动指示器
    self.showsHorizontalScrollIndicator = YES;
}
@end
